def update_direction(curr_direction, diff):
    output = 0
    if curr_direction == 1 and diff[0] == 1:
        curr_direction = 1
        return curr_direction, output
    elif curr_direction == 2 and diff[1] == 1:
        curr_direction = 2
        return curr_direction, output
    elif curr_direction == -1 and diff[0] == -1:
        curr_direction = -1
        return curr_direction, output
    elif curr_direction == -2 and diff[1] == -1:
        curr_direction = -2
        return curr_direction, output

    elif curr_direction == 1 and diff[0] == -1:
        curr_direction = -1
        output = 3
        return curr_direction, output
    elif curr_direction == 2 and diff[1] == -1:
        curr_direction = -2
        output = 3
        return curr_direction, output
    elif curr_direction == -1 and diff[0] == 1:
        curr_direction = 1
        output = 3
        return curr_direction, output
    elif curr_direction == -2 and diff[1] == 1:
        curr_direction = 2
        output = 3
        return curr_direction, output

    elif curr_direction == 1 and diff[1] == 1:
        curr_direction = 2
        output = 2
        return curr_direction, output
    elif curr_direction == 2 and diff[0] == -1:
        curr_direction = -1
        output = 2
        return curr_direction, output
    elif curr_direction == -1 and diff[1] == -1:
        curr_direction = -2
        output = 2
        return curr_direction, output
    elif curr_direction == -2 and diff[0] == 1:
        curr_direction = 1
        output = 2
        return curr_direction, output

    elif curr_direction == 1 and diff[1] == -1:
        curr_direction = -2
        output = 1
        return curr_direction, output
    elif curr_direction == 2 and diff[0] == 1:
        curr_direction = 1
        output = 1
        return curr_direction, output
    elif curr_direction == -1 and diff[1] == 1:
        curr_direction = 2
        output = 1
        return curr_direction, output
    elif curr_direction == -2 and diff[0] == -1:
        curr_direction = -1
        output = 1
        return curr_direction, output

    else:
        return curr_direction, output
